<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qqmlparserstatus.cpp -->
  <title>QQmlParserStatus  类 | Qt QML 5.12.3</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.12</a></td><td ><a href="qtqml-index.html">Qt QML</a></td><td ><a href="qtqml-module.html">
			C++ <span lang="zh-cn">类</span></a></td><td >QQmlParserStatus</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtqml-index.html">Qt 5.12.3 参考指南</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">目录</a></h3>
<ul>
<li class="level1"><a href="#public-functions">公用函数</a></li>
<li class="level1"><a href="#details">详细信息</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QQmlParserStatus 类</h1>
<!-- $$$QQmlParserStatus-brief -->
<p><a href="qqmlparserstatus.html">QQmlParserStatus</a>类提供关于QML解析器状态的更新。 <a href="#details">更多...</a></p>
<!-- @@@QQmlParserStatus -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> 头文件：</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QQmlParserStatus&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += qml</td></tr><tr><td class="memItemLeft rightAlign topAlign"> 
	<span lang="zh-cn">从：</span></td><td class="memItemRight bottomAlign">  Qt 5.0</td></tr></table></div><ul>
<li><a href="qqmlparserstatus-members.html"></a></li>
</ul>
<a name="public-functions"></a>
<h2 id="public-functions">公用函数</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qqmlparserstatus.html#classBegin">classBegin</a></b>() = 0</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qqmlparserstatus.html#componentComplete">componentComplete</a></b>() = 0</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QQmlParserStatus-description -->
<div class="descr">
<h2 id="details">详细信息</h2>
<p><a href="qqmlparserstatus.html">QQmlParserStatus</a>类提供关于QML解析器状态的更新。</p>
<p><a href="qqmlparserstatus.html">QQmlParserStatus</a>为<a href="qqmlengine.html">QQmlEngine</a>实例化的类提供了一种机制，以便在它们创建的关键点接收通知。</p>
<p>这个类通常用于优化目的，因为它允许您推迟昂贵的操作，直到在对象上设置了所有属性之后。例如，QML的<a href="../qtquick/qml-qtquick-text.html">Text</a>元素使用解析器状态来延迟文本布局，直到它的所有属性都设置好(我们不希望在分配文本时进行布局，在分配字体时进行重新布局，在分配宽度时再次进行重新布局，等等)。</p>
<p>请注意，<a href="qqmlparserstatus.html">QQmlParserStatus</a>方法只在<a href="qqmlengine.html">QQmlEngine</a>实例化类时调用。如果您直接从C++创建相同的类，这些方法将不会被自动调用。为了避免这个问题，建议从<a href="qqmlparserstatus.html#classBegin">classBegin</a>而不是从类的初始创建开始延迟操作。这仍然可以防止QML中初始绑定赋值期间的多次重估，但不会推迟从C++调用的操作。</p>
<p>要使用<a href="qqmlparserstatus.html">QQmlParserStatus</a>，您必须继承<a href="../qtcore/qobject.html">QObject</a>派生类和<a href="qqmlparserstatus.html">QQmlParserStatus</a>，并使用<a href="../qtcore/qobject.html#Q_INTERFACES">Q_INTERFACES</a>()宏。</p>
<pre class="cpp">

  <span class="keyword">class</span> MyObject : <span class="keyword">public</span> <span class="type"><a href="../qtcore/qobject.html">QObject</a></span><span class="operator">,</span> <span class="keyword">public</span> <span class="type">QQmlParserStatus</span>
  {
      Q_OBJECT
      Q_INTERFACES(<span class="type">QQmlParserStatus</span>)

  <span class="keyword">public</span>:
      MyObject(<span class="type"><a href="../qtcore/qobject.html">QObject</a></span> <span class="operator">*</span>parent <span class="operator">=</span> <span class="number">0</span>);
      <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
      <span class="type">void</span> classBegin();
      <span class="type">void</span> componentComplete();
  }

</pre>
</div>
<!-- @@@QQmlParserStatus -->
<div class="func">
<h2>成员函数的文档</h2>
<!-- $$$classBegin[overload1]$$$classBegin -->
<h3 class="fn" id="classBegin"><a name="classBegin"></a><code>[pure virtual] </code><span class="type">void</span> QQmlParserStatus::<span class="name">classBegin</span>()</h3>
<p>在创建类之后，但在设置任何属性之前调用。</p>
<!-- @@@classBegin -->
<!-- $$$componentComplete[overload1]$$$componentComplete -->
<h3 class="fn" id="componentComplete"><a name="componentComplete"></a><code>[pure virtual] </code><span class="type">void</span> QQmlParserStatus::<span class="name">componentComplete</span>()</h3>
<p>在导致此实例化的根组件完成构造之后调用。此时，所有静态值和绑定值都已分配给类。</p>
<!-- @@@componentComplete -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
